package com.zz.common.codeGenerator.common;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * 读取代码生成相关配置
 *
 * @author ruoyi
 */
@Component
@Primary
@ConfigurationProperties(prefix = "gen")
@PropertySource(value = {"classpath:conf/generator.yml"})
public class GenConfig {
    /**
     * 作者
     */
    public static String author;

    /**
     * 生成包路径
     */
    public static String packageName;

    /**
     * 自动去除表前缀，默认是false
     */
    public static boolean autoRemovePre;

    /**
     * 表前缀(类名不会包含表前缀)
     */
    public static String tablePrefix;

    /**
     * 自动去除表后缀，默认是true
     */
    public static boolean autoRemoveSuf;

    /**
     * 表后缀(类名不会包含表后缀)
     */
    public static String tableSuffix;

    /**
     * 是否开启springdoc，默认是true
     */
    public static String enableSpringdoc;

    /**
     * 是否开启lombok，默认是true
     */
    public static String enableLombok;

    /**
     * 后台生成的方法
     */
    public static String method;

    public static String getAuthor() {
        return author;
    }

    @Value("${author}")
    public void setAuthor(String author) {
        GenConfig.author = author;
    }

    public static String getPackageName() {
        return packageName;
    }

    @Value("${packageName}")
    public void setPackageName(String packageName) {
        GenConfig.packageName = packageName;
    }

    public static boolean getAutoRemovePre() {
        return autoRemovePre;
    }

    @Value("${autoRemovePre}")
    public void setAutoRemovePre(boolean autoRemovePre) {
        GenConfig.autoRemovePre = autoRemovePre;
    }

    public static String getTablePrefix() {
        return tablePrefix;
    }

    @Value("${tablePrefix}")
    public void setTablePrefix(String tablePrefix) {
        GenConfig.tablePrefix = tablePrefix;
    }

    public static boolean getAutoRemoveSuf() {
        return autoRemoveSuf;
    }

    @Value("${autoRemoveSuf}")
    public void setAutoRemoveSuf(boolean autoRemoveSuf) {
        GenConfig.autoRemoveSuf = autoRemoveSuf;
    }

    public static String getTableSuffix() {
        return tableSuffix;
    }

    @Value("${tableSuffix}")
    public void setTableSuffix(String tableSuffix) {
        GenConfig.tableSuffix = tableSuffix;
    }

    public static String getEnableSpringdoc() {
        return enableSpringdoc;
    }

    @Value("${enableSpringdoc}")
    public void setEnableSpringdoc(String enableSpringdoc) {
        GenConfig.enableSpringdoc = enableSpringdoc;
    }

    public static String getEnableLombok() {
        return enableLombok;
    }

    @Value("${enableLombok}")
    public void setEnableLombok(String enableLombok) {
        GenConfig.enableLombok = enableLombok;
    }

    public static String getMethod() {
        return method;
    }

    @Value("${method}")
    public void setMethod(String method) {
        GenConfig.method = method;
    }
}
